package com.springbootxuexi.domain;

import com.fasterxml.jackson.annotation.JsonProperty;

public class JsonResponse<T> {

    @JsonProperty(value="code")
    private Integer error_code;
    @JsonProperty(value = "msg")
    private String message;
    @JsonProperty(value="data")
    private T data;

    public JsonResponse(Integer error_code, String message, T data) {
        this.error_code = error_code;
        this.message = message;
        this.data = data;
    }
    public JsonResponse(ErrorCodes errCode, T data) {
        this.error_code = errCode.getErrcode();
        this.message = errCode.getMsg();
        this.data = data;
    }
    public JsonResponse(ErrorCodes errCode) {
        this.error_code = errCode.getErrcode();
        this.message = errCode.getMsg();
        this.data = null;
    }

    public Integer getError_code() {
        return error_code;
    }

    public void setError_code(Integer error_code) {
        this.error_code = error_code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
